package com.rc.evcharger.service.member;

import com.rc.evcharger.mapper.member.MemberAccountMapper;
import com.rc.evcharger.model.member.MemberAccount;
import com.rc.evcharger.model.member.MemberAccountExample;
import com.rc.evcharger.model.order.OrderInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * Created by sven on 2019/09/23.
 */
@Service
public class MemberAccountServiceImpl implements MemberAccountService {

    @Autowired
    private MemberAccountMapper memberAccountMapper;

    @Override
    public MemberAccountMapper getMapper() {
        return memberAccountMapper;
    }

    @Override
    public MemberAccount selectByMemberId(Long memberId, String tenantCode) {
        MemberAccountExample memberAccountExample = new MemberAccountExample();
        memberAccountExample.createCriteria().andMemberIdEqualTo(memberId).andTenantCodeEqualTo(tenantCode);
        List<MemberAccount> list = memberAccountMapper.selectByExample(memberAccountExample);
        if (!CollectionUtils.isEmpty(list)) {
            return list.get(0);
        }
        return null;
    }

    @Override
    public int updateGiveAmountByMember(OrderInfo orderInfo) {
        return 0;
    }
}
